package com.smart.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.smart.util.AuthorityMenuUtil;

@Controller
public class AuthorityMenu {
	   //根据权限动态返回菜单
	   @RequestMapping(value="/pc/authority_menu", method = RequestMethod.POST)
	   public void authorityMenu(HttpServletRequest req,HttpServletResponse resp) 
	   {
		   System.out.println("authority_menu method start......");
		   HttpSession session=req.getSession();
//		   Admin admin=(Admin)session.getAttribute("admin");
		   //获取当前用户权限
//		   int type=admin.getType();//1表示快递管理员，0表示普通管理员，2表示超级管理员
//		   System.out.println("type:"+type);
		   String role=session.getAttribute("role").toString();
		   System.out.println("role:"+role);
		   String menu=AuthorityMenuUtil.getMenu(role);
		   PrintWriter out=null;
		   try {
			resp.setCharacterEncoding("utf-8");
			out=resp.getWriter();
			out.print(menu);
			System.out.println(menu);
			out.flush();
		   } catch (IOException e) {
			e.printStackTrace();
		  }
		  finally
		  {
			  if(out!=null)  out.close();
		  }
		   System.out.println("authority_menu method finish......");
	   }
	   
	   public static void main(String[] args)
	   {
		   
	   }
}
